package chapter4;

import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.StatusLineManager;
import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.jface.window.ApplicationWindow;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;

public class statusContributions extends ApplicationWindow {
	
	StatusLineManager slm = new StatusLineManager();
	statusAction sa = new statusAction(slm);
	
	ActionContributionItem aci = new ActionContributionItem(sa);
	
	public statusContributions() {
		super(null);
		
		addStatusLine();
		addMenuBar();
		addToolBar( SWT.FLAT | SWT.WRAP);
	}
	
	@Override
	protected Control createContents(Composite parent) {
		getShell().setText("action/contribution example");
		parent.setSize(290, 150);
		
		aci.fill(parent);
		parent.pack();
		return parent;
	}
	
	public static void main(String[] args) {
		statusContributions sc = new statusContributions();
		
		sc.setBlockOnOpen(true);
		sc.open();
		
		Display.getCurrent().dispose();
	}
	
	//
	
	@Override
	protected MenuManager createMenuManager() {
		MenuManager menu = new MenuManager(null);
		MenuManager actionMenu = new MenuManager("menu");
		menu.add(actionMenu);
		actionMenu.add(sa);
		return menu;
	}
	
	@Override
	protected ToolBarManager createToolBarManager(int style) {
		ToolBarManager toolbarmanager = new ToolBarManager(style);
		toolbarmanager.add(sa);
		return toolbarmanager;
	}
	
	@Override
	protected StatusLineManager createStatusLineManager() {		
		return slm;
	}

}
